#ifndef _OI_PLSCANNERCORE_DATABASE_HPP_
#define _OI_PLSCANNERCORE_DATABASE_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        struct OI_PLSCANNER_CORE_API DataRow
        {
            int result;
            QDateTime datetime;
            QString formula;
            QString user;
            
            float fullHeight;
            float waistHeight;
            float endPointWidth;
            float waistWidth;
            float bottomWidth;
            float area;
        };

        class OI_PLSCANNER_CORE_API Database : public QObject
        {
            Q_OBJECT

        public:
            Database();
            ~Database();

        public:
            QString tableName() const;

            bool open();

        public:
            bool query(const QStringList keys, QMap<QString, QList<QPointF>>&, const QDateTime from, const QDateTime end);

            QStringList group(const QString key, const QString db);

        public:
            bool insert(const DataRow&);
            void keepDatas(int days);

        public:
            static Database* instance();

        private:
            OI_DISABLE_COPY(Database);
            OI_DECLARE_IMPL(Database);
        };
    }
}

#endif
